<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <script src="../layui/layui.js"></script>
</head>

<body>
    <button type="button" class="layui-btn" id="add">默认按钮</button>
    <div class="demo"></div>
    <img jm-src="../avatar_1.jpg" width="100" />
</body>
<script>
    // 配置
    layui.config({
        base: "../model/",
        version: true
    })

    layui.use(["jquery", "jmImg"], function () {
        var $ = layui.$;
        var jmImg = layui.jmImg;

        /** 
         * 图片加载优化开启
         * img中属性 jm-src 为要显示的图片地址
         */
        jmImg.start("../加载中.gif");
        //jmImg.stop();//关闭优化


        $("#add").click(function () {
            $(".demo").append(`
                <img jm-src="../avatar_2.png" width="100" />
                <img src="../dota_火女.png" width="100" />
            `);
        })


    })
</script>

</html>